import requests

# 添加路径参数:
# r = requests.get("http://192.168.41.120:9999/news/json/1")
# print(r.json())

# 添加query参数第一种:
# r = requests.get("http://192.168.41.120:9999/news_list?cid=3&page=2")
# print(r.json())

# 添加query参数第二种:
# data = {"cid": 1, "page": 1}
# r = requests.get("http://192.168.41.120:9999/news_list", params=data)
# print(r.json())

# 添加from文本参数
# data = {"mobile": "13467265747", "password": "123456"}
# r = requests.post("http://192.168.41.120:9999/passport/login", data=data)
# print(r.json())

# 添加请求头,cookie,纯文本请求体
# header = {"Content-Type": "application/json"}
# cookie = {"session": "5e8b820c-9c04-43c0-9340-5509eadb291d.XtNbfRmjun8WFuB5l0K7Yr1p4mY"}
# data = '{"news_id": "1","comment": "小黑子"}'.encode("utf-8")
# r = requests.post("http://192.168.41.120:9999/news/news_comment", headers=header, cookies=cookie, data=data)
# print(r.json())

# 添加form文件
# cookie = {"session": "5e8b820c-9c04-43c0-9340-5509eadb291d.XtNbfRmjun8WFuB5l0K7Yr1p4mY"}
# with open("a.png", "rb") as f:
#     file = {"avatar": f}
#     r = requests.post("http://192.168.41.120:9999/user/pic_info", files=file, cookies=cookie)
# print(r.text)



# 新闻发布
# data = {"title": "唱跳+rap+篮球,中国第一人","category_id": 1,"digest": "蔡徐坤（KUN）中国内地男演员","content": "荔枝，你让我拿什么荔枝啊？我爱的那个牠都被你们这样对待了，还让我怎么荔枝，啊？看着牠被你们骂得狗血淋头我还坐视不管这就叫荔枝了吗？！"}
# r = requests.post("http://192.168.41.120:9999/user/news_release", data=data, cookies=cookie)
# print(r.json())
